package educar.gui;

import java.sql.SQLException;

import javax.swing.JOptionPane;

import educar.controllers.BajaFacultadController;
import educar.controllers.IController;
import educar.controllers.ModificarDatosController;
import educar.db.JPA;

public class BajaFacultadView extends javax.swing.JFrame implements IView {

    /** Creates new form BajaFacultadView */
    public BajaFacultadView() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    	String [] facultades=null;
    	JPA jpa= new JPA();
        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("DejaVu Sans", 3, 14)); // NOI18N
        jLabel1.setText("BAJA FACULTAD");
        
        try {
			facultades= jpa.getConsulta("facultad", "nombre", "nombre=nombre");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel (facultades));//(new String[] { "Cs. Exactas Fisico-Quimico y Naturales", "Humanas", "Agronomia y Veterinaria", "Ingenieria", "Cs. Economicas" }));

        jButton1.setText("Aceptar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(134, 134, 134)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(105, 105, 105)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(149, 149, 149)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(90, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(37, 37, 37)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(jButton1)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        pack();
        
       
        
        LoginListener buttonListener3 = new LoginListener();
    	IController loginController3 = new BajaFacultadController();
    	loginController3.setView(this);
    	buttonListener3.associate(jButton1, loginController3);
    }// </editor-fold>
    public String getFacultad(){
		
        return (String) jComboBox1.getSelectedItem();
} 
    
    public void present(String model) {
		JOptionPane.showMessageDialog(null, model);
	}

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration
    /**
     *
    * @param args the command line arguments
    */
    
    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new BajaFacultadView().setVisible(true);
            }
        });
    }
    
  

}